Skip to content

Fix empty fs_uuid on multi-device Btrfs#440

Open
mkocustos wants to merge 1 commit into
Antynea:masterfrom
mkocustos:fix/multi-device-btrfs-fs-uuid
Open

Fix empty fs_uuid on multi-device Btrfs#440
mkocustos wants to merge 1 commit into
Antynea:masterfrom
mkocustos:fix/multi-device-btrfs-fs-uuid

Conversation

@mkocustos

Copy link
Copy Markdown

Problem

On a multi-device Btrfs filesystem, grub-probe --target=device / prints one device per line, e.g.:

/dev/vda3
/dev/vdb

The whole multi-line value is then passed to grub-probe --device "${root_device}" --target=fs_uuid, which cannot handle several devices at once and returns an empty string. The blkid fallback fails for the same reason (it gets a multi-line device argument), so 41_snapshots-btrfs aborts with:

Cannot determine UUID of /dev/vda3 /dev/vdb

This makes grub-btrfs unusable on any multi-device Btrfs (RAID0/1/10, single-profile with added devices, etc.). The affected line was introduced in #378.

Fix

Pipe the device probe through head -n1 and keep only the first member device. Every member of a Btrfs pool reports the same pool-wide fs UUID, so the first device is sufficient. For single-device setups head -n1 is a no-op, so existing configurations are unaffected.

The identical one-line-per-device behaviour applies to a /boot that lives on a multi-device Btrfs, so the same guard is added to boot_device for consistency.

Testing

Reproduced and verified on Fedora Server 43, root on a 2-device Btrfs (/dev/vda3 + /dev/vdb), /boot on a separate single-device XFS partition. Before the fix grub-mkconfig aborted with the "Cannot determine UUID" error; after the fix the correct fs UUID is resolved and grub-btrfs.cfg is generated as expected. bash -n passes.

On a multi-device Btrfs filesystem `grub-probe --target=device /` prints
one device per line (e.g. /dev/vda3 and /dev/vdb). The whole multi-line
result was then passed to `grub-probe --device "${root_device}"
--target=fs_uuid`, which cannot handle several devices at once and
returns an empty string. The blkid fallback fails for the same reason,
so grub-btrfs aborts with "Cannot determine UUID".

Pipe the device probe through `head -n1` and keep only the first member
device. Every member of a Btrfs pool reports the same pool-wide fs UUID,
so the first device is sufficient. For single-device setups `head -n1`
is a no-op, so existing configurations are unaffected.

The same one-line-per-device behaviour applies to a /boot that lives on
a multi-device Btrfs, so the identical guard is added to boot_device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant